//
//  VKMineCell.m
//  V-Learn
//
//  Created by liubo on 2019/1/2.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKMineCell.h"

@implementation VKMineCell{
    UIImageView *_imageView;
    UILabel *_titleLabel;
    UIView *_lineView;
    UIImageView *_arrowImage;
}
- (void)setModel:(VKMineModel *)model{
    _model = model;
    
    _imageView.image = [UIImage imageNamed:model.imageString];
    _titleLabel.text = model.titleString;
    
    
}
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKMineCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKMineCell"];
    if (cell == nil) {
        cell = [[VKMineCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKMineCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 布局子控件
        [self autoLayout];
    }
    return self;
}
- (void)autoLayout{
    // 图片
    _imageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_imageView];
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(@18);
//        make.width.height.equalTo(@18);
        make.left.mas_equalTo(18*ScaleX);
        make.width.height.equalTo(18*ScaleX);

        make.centerY.equalTo(self.contentView);
    }];
    // 标题
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.textColor = [UIColor cz_colorWithHex:0x020202];
//    _titleLabel.font = [UIFont systemFontOfSize:16];
    _titleLabel.textColor = [UIColor cz_colorWithRed:51 green:51 blue:51];
    [self.contentView addSubview:_titleLabel];
    __weak typeof(_imageView) weakImageView = _imageView;
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakImageView.mas_right).offset(13*ScaleX);
        make.centerY.equalTo(self.contentView);
    }];
    UIImageView *arrowImage = [[UIImageView alloc]init];
    _arrowImage = arrowImage;
    arrowImage.image = [UIImage imageNamed:@"left"];
    [self.contentView addSubview:arrowImage];
    [arrowImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-19*ScaleX));
//        make.width.equalTo(@9);
//        make.height.equalTo(@15);
        make.size.mas_equalTo(CGSizeMake(9*ScaleX, 15*ScaleX));
        make.centerY.equalTo(self.contentView);
    }];
    UIView *lineView = [[UIView alloc]init];
    [self.contentView addSubview:lineView];
    _lineView = lineView;
    lineView.backgroundColor = [UIColor cz_colorWithRed:240 green:240 blue:240];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.equalTo(@1);
        make.height.mas_equalTo(1*ScaleX);
        make.left.right.bottom.equalTo(self.contentView);
    }];
    
    self.priceLab = [UILabel labelWithText:@"0 乐学币" andTextColor:[UIColor cz_colorWithRed:153 green:153 blue:153] andName:nil andFontSize:15*ScaleX];
    [self.contentView addSubview:self.priceLab];
    [self.priceLab makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(arrowImage.mas_left).mas_equalTo(-7*ScaleX);
        make.centerY.mas_equalTo(self.contentView);
    }];
}

@end
